package info.xiao.dataStructrue.array;

/**
 * @Classname FindPoisonedDuration
 * @Description 提莫攻击
 * @Url https://leetcode.cn/problems/teemo-attacking/
 * @Date 2023/4/10 10:53
 * @Created by 晓龙Oba
 */
public class FindPoisonedDuration {
    public static void main(String[] args) {
        int[] nums = {1, 2};
        int duration = 2;
        int result = findPoisonedDuration(nums, duration);
        System.out.println(result);
    }

    private static int findPoisonedDuration(int[] nums, int duration) {
        int result = duration;
        int flag = 1;
        for (int i = 0; i < nums.length - 1; i++) {
            flag += duration;
            if (nums[i] + duration < nums[i + 1]) {
                result += duration;
            } else {
                result += nums[i + 1] - nums[i];
            }
        }
        return result;
    }
}
